/*
*  Impp - Instant Messenger
*
*  Copyright (C) 2008  Oliver Schneider
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
#ifndef CHATWINDOW_H_
#define CHATWINDOW_H_


#include "ChatPanel.h"

#include "../../core/interfaces/iChatWindow.h"
#include "../../core/interfaces/iUserInterface.h"
#include "../../core/Buddy.h"
#include "../../core/events/MessageEvent.h"
#include "../../core/events/MessageCallbackEvent.h"
#include "../../core/events/TypingNotificationEvent.h"
#include "../../core/events/StatusEvent.h"
#include "../../core/events/AvatarChangedEvent.h"
#include "../../core/events/FileTransfareEvent.h"
#include "../../core/events/MessageReadEvent.h"
#include "../../core/events/ImppCommandEvent.h"
#include "../../core/utils/ButtonList.h"

#include "ImppNotebook.h"
#include "events/NotebookPageClosedEvent.h"
#include "StdChatWindowModule.h"



namespace Impp
{

class ChatPanel;
class StdChatWindowModule;

class ChatWindow : public wxFrame
{

private:
	ImppNotebook* pages;
	ChatPanel* lastAdded;
	ButtonList* buttonList;

	enum{
		ID_TABS = wxID_HIGHEST + 1,
		ID_CHATWIN,
		ID_CLOSE_WINDOW
	};

	enum{
		ICON_NEW_MSG = 0
	};

public:
	ChatWindow(StdChatWindowModule* module);
	virtual ~ChatWindow();

	ChatPanel* show(Buddy* b, bool showWin, bool selectTab);

	void close(Buddy* b);


	void onMessageIn(MessageEvent & event);
	void onMessageCallback(MessageCallbackEvent & event);
	void onTypingNotification(TypingNotificationEvent & event);
	void onStatusChanged(StatusEvent & event);
	void onAvatarChanged(AvatarChangedEvent & event);
	void onIncomingFile(FileTransfareEvent & event);
	void closed(wxCloseEvent & event);
	void onPageClose(NotebookPageClosedEvent & event);
	void onPageChaned(wxNotebookEvent & event);
	void onActivate(wxActivateEvent & event);
	void onMessageRead(MessageReadEvent & event);
	void onCloseWindow(wxCommandEvent & event);
	ChatPanel* updateWindowTitle();
	void showChatWindow(Buddy* buddy);
	void addActionButtion(const wxString & moduleName, const wxString & actionName, const wxString & title, const wxString & description);
	ButtonList* getButtonList();
	bool hasBuddy(Buddy* buddy);

private:
	void setUnreadMsg(Buddy* buddy, bool unreadMsgs);
	int statusToIconsId(const Status & status);

private:
	DECLARE_EVENT_TABLE()

};

}

#endif /*CHATWINDOW_H_*/
